package okw.database;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class VotingSubcard extends core.modules.database.SuperVotingSubcard
		implements Serializable {

	private static final long serialVersionUID = -4233924730273510566L;

	private VotingCard votingCard;
	private Set<VotingSubcardOption> votingSubcardOptions = new HashSet<VotingSubcardOption>();

	public VotingSubcard() {
		super();
	}

	public VotingSubcard(String name, String description, int allowedChecks) {
		super(name, description, allowedChecks);
	}

	public VotingCard getVotingCard() {
		return votingCard;
	}

	public void setVotingCard(VotingCard votingCard) {
		this.votingCard = votingCard;
	}

	public Set<VotingSubcardOption> getVotingSubcardOptions() {
		return votingSubcardOptions;
	}
	
	public void addToVotingCard(VotingCard votingCard){
		this.setVotingCard(votingCard);
		votingCard.getVotingSubcards().add(this);
	}
	
	public void removeFromVotingCard(VotingCard votingCard){
		this.setVotingCard(null);
		votingCard.getVotingSubcards().remove(this);
	}

	public void setVotingSubcardOptions(
			Set<VotingSubcardOption> votingSubcardOptions) {
		this.votingSubcardOptions = votingSubcardOptions;
	}
	
	public void addToVotingSubcardOption(VotingSubcardOption votingSubcardOption){
		this.getVotingSubcardOptions().add(votingSubcardOption);
		votingSubcardOption.setVotingSubcard(this);
	}
	
	public void removeFromVotingSubcardOption(VotingSubcardOption votingSubcardOption){
		this.getVotingSubcardOptions().remove(votingSubcardOption);
		votingSubcardOption.setVotingSubcard(null);
	}
}
